
for /l %%x in (0,0,1) do (
    for /F "eol=; tokens=* delims=" %%y in (hostlist.txt) do (
        set HOST=%%y
        if "%1"=="ping" (
            call :ping
        ) else (
            call :keepAlive
        )
    )
)

:keepAlive
    wget "http://hzj-jie.net:800/snapshot?height=2048&url=http%%3A%%2F%%2Fjust-dnslookup.com%%2Findex.php%%3Fvh%%3D%HOST%" -O temp.txt
    wget "http://network-tools.com/default.asp?prog=ping&host=%HOST%" -O temp.txt
    wget "http://hzj-jie.net:800/snapshot?url=http%%3A%%2F%%2Fping.chinaz.com%%2F%%3Fhost%%3D%HOST%" -O temp.txt
    del temp.txt
    sleep 5m
goto :eof

:ping
    ping %HOST%
    if ERRORLEVEL 1 (
        ipconfig /flushdns
        ping %HOST% )
    sleep 5s
goto :eof

:finish

